package com.fr.report.core.headerfooter;

import com.fr.base.core.GraphHelper;
import com.fr.base.core.serializable.ImageSerializable;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.geom.Dimension2D;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class ImageHFElement extends AbstractHFElement
{
  private transient Image image;
  private int width;
  private int height;

  public ImageHFElement()
  {
    this(null);
  }

  public ImageHFElement(Image paramImage)
  {
    this.image = null;
    this.width = 0;
    this.height = 0;
    setImage(paramImage);
  }

  public ImageHFElement(Image paramImage, int paramInt1, int paramInt2)
  {
    this.image = null;
    this.width = 0;
    this.height = 0;
    setImage(paramImage);
    setWidth(paramInt1);
    setHeight(paramInt2);
  }

  public Image getImage()
  {
    return this.image;
  }

  public void setImage(Image paramImage)
  {
    this.image = paramImage;
    if (paramImage != null)
    {
      GraphHelper.waitForImage(this.image);
      setWidth(this.image.getWidth(null));
      setHeight(this.image.getHeight(null));
    }
  }

  public int getWidth()
  {
    return this.width;
  }

  public void setWidth(int paramInt)
  {
    this.width = paramInt;
  }

  public int getHeight()
  {
    return this.height;
  }

  public void setHeight(int paramInt)
  {
    this.height = paramInt;
  }

  public Dimension2D getSize()
  {
    return new Dimension(getWidth(), getHeight());
  }

  private void readObject(ObjectInputStream paramObjectInputStream)
    throws ClassNotFoundException, IOException
  {
    paramObjectInputStream.defaultReadObject();
    Object localObject = paramObjectInputStream.readObject();
    if (localObject != null)
      this.image = ((ImageSerializable)localObject).getImage();
  }

  private void writeObject(ObjectOutputStream paramObjectOutputStream)
    throws IOException
  {
    paramObjectOutputStream.defaultWriteObject();
    if (this.image != null)
    {
      ImageSerializable localImageSerializable = new ImageSerializable(this.image);
      paramObjectOutputStream.writeObject(localImageSerializable);
    }
  }
}